﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using ExampleApp.Common;
using StyleMVVM.DependencyInjection;
using StyleMVVM.ViewModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ExampleApp.ViewModels
{

	public class MainPageViewModel : PageViewModel
	{
		private List<IDemoPageInfo> demoPages;

		public IEnumerable<IDemoPageInfo> DemoPages
		{
			get { return demoPages; }
		}

		[ImportMethod]
		public void ImportPages(IEnumerable<IDemoPageInfo> demoPageInfos)
		{
			demoPages = new List<IDemoPageInfo>(demoPageInfos);

			demoPages.Sort((x, y) => string.Compare(x.Title, y.Title));
		}

		public void ItemClick(ItemClickEventArgs args)
		{
			IDemoPageInfo demoPage = args.ClickedItem as IDemoPageInfo;

			if (demoPage != null)
			{
				Navigation.Navigate(demoPage.ViewName);
			}
		}
	}
}
